﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//using UnityEditor.UI;
using UnityEditor;

public partial class AutoQuoteMenu
{
    private static bool IsClear = false;

    [MenuItem("Plateface/AutoRef/OpenRefWindow")]
    public static void OpenWindow()
    {
        AutoQuoteEditorWindow thisWindow = EditorWindow.GetWindow<AutoQuoteEditorWindow>(false, "AutoRef", false);
    }

    [MenuItem("Plateface/AutoRef/SetName# &3")]
    public static void SetGameName()
    {
        GameObject o = Selection.activeGameObject;
        if (o == null)
            return;

        string name = o.name;
        if (name.StartsWith("#"))
        {
            name = name.Substring(1);
            o.name = name;
        }
        else
        {
            name = name.Insert(0, "#");
            o.name = name;
        }
    }


    [MenuItem("Plateface/AutoRef/SetRef &2")]
    public static void SetRefMenu()
    {
        GameObject o = Selection.activeGameObject;
        if (o == null)
            return;

        Component[] cAry = o.GetComponents<Component>();
        foreach (var c in cAry)
        {
            System.Type componentType = c.GetType();
            if (IsHasAttribute(componentType))
            {
                AutoSetRef(c, o, IsClear);
            }
        }

        IsClear = !IsClear;
    }




    [MenuItem("Plateface/AutoRef/Generate Code")]
    public static void AutoCreateCodeMenu()
    {
        GameObject o = Selection.activeGameObject;
        if (o == null)
            return;

        AutoCreateCode(o);
    }

}
